package blog.spring.db.entity;

// Generated 2015-1-30 0:04:13 by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * ArticleInfo generated by hbm2java
 */
@Entity
@Table(name = "article_info", catalog = "blog")
public class ArticleInfo implements java.io.Serializable {

	private Integer articleId;
	@JsonIgnore
	// 返回JSON不加载此依赖
	private Type type;
	@JsonIgnore
	// 返回JSON不加载此依赖
	private User user;
	private String title;
	@JsonIgnore
	// 返回JSON不加载此依赖
	private String beviaryContent;
	private boolean isTop;
	private boolean allowComment;
	private Integer weight;
	private int sort;
	private Date createDate;
	private int commentCount;
	private Date updateDate;
	@JsonIgnore
	// 返回JSON不加载此依赖
	private ArticleContent articleContent;
	@JsonIgnore
	// 返回JSON不加载此依赖
	private List<Lable> lables = new ArrayList<Lable>();
	@JsonIgnore
	// 返回JSON不加载此依赖
	private List<Comment> comments = new ArrayList<Comment>();

	public ArticleInfo() {
	}

	public ArticleInfo(Integer articleId) {
		super();
		this.articleId = articleId;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "articleInfo", cascade = CascadeType.ALL)
	@PrimaryKeyJoinColumn
	public ArticleContent getArticleContent() {
		return this.articleContent;
	}

	public void setArticleContent(ArticleContent articleContent) {
		this.articleContent = articleContent;
		if (articleContent != null)
			this.articleContent.setArticleInfo(this);
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "article_id", unique = true, nullable = false)
	public Integer getArticleId() {
		return this.articleId;
	}

	public void setArticleId(Integer articleId) {
		this.articleId = articleId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type_id")
	public Type getType() {
		return this.type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "title")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "beviary_content", length = 65535)
	public String getBeviaryContent() {
		return this.beviaryContent;
	}

	public void setBeviaryContent(String beviaryContent) {
		this.beviaryContent = beviaryContent;
	}

	@Column(name = "is_top", nullable = false)
	public boolean isIsTop() {
		return this.isTop;
	}

	public void setIsTop(boolean isTop) {
		this.isTop = isTop;
	}

	@Column(name = "allow_comment", nullable = false)
	public boolean isAllowComment() {
		return this.allowComment;
	}

	public void setAllowComment(boolean allowComment) {
		this.allowComment = allowComment;
	}

	@Column(name = "weight")
	public Integer getWeight() {
		return this.weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	@Column(name = "sort", nullable = false)
	public int getSort() {
		return this.sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_date", length = 19)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "comment_count", nullable = false)
	public int getCommentCount() {
		return this.commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_date", length = 19)
	public Date getUpdateDate() {
		return this.updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "article_lable", catalog = "blog", joinColumns = { @JoinColumn(name = "article_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "lable_id", nullable = false, updatable = false) })
	public List<Lable> getLables() {
		return this.lables;
	}

	public void setLables(List<Lable> lables) {
		this.lables = lables;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "articleInfo", cascade = CascadeType.REMOVE)
	public List<Comment> getComments() {
		return this.comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

}
